package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.service.LitemallQuoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wx/quote")
public class WxQuoteController {
    @Autowired
    LitemallQuoteService quoteService;

    /**
     *
     * @param msg  brandId     pid
     * @return
     */

    @PostMapping("/view")
    public Object view(@RequestBody String msg) {
        Integer brandId = JacksonUtil.parseInteger(msg, "brandId");
        Integer pid = JacksonUtil.parseInteger(msg, "pid");
        if (pid == null || brandId == null) {
            return ResponseUtil.badArgument();
        }
        return ResponseUtil.ok(quoteService.findByPid(pid, brandId));
    }
}
